/*
*    Qizx/open 3.0 beta
*
* This code is the open-source version of Qizx.
* Copyright (C) 2004-2009 Axyana Software -- All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License 
*  Version 1.1 (the "License"); you may not use this file except in 
*  compliance with the License. You may obtain a copy of the License at
*  http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
*  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
*  for the specific language governing rights and limitations under the
*  License.
*
* The Initial Developer of the Original Code is Xavier Franc - Axyana Software.
*
*/
using System;
using System.Xml;
using WordSieve = System.Qizx.Api.Indexing.WordSieve;
using FullTextFactory = System.Qizx.Api.FullText.FullTextFactory;
using DefaultFullTextFactory = System.Qizx.Api.Util.FullText.DefaultFullTextFactory;
using DefaultWordSieve = System.Qizx.Api.Util.DefaultWordSieve;
namespace System.Qizx.Api {

    /// <summary> Simple XQuery session without access to XML Libraries, used in Qizx/open.</summary>
    public interface XQuerySession : ItemFactory {
        /// <summary>
        /// Access to the default XQuery Context. This context is inherited
        /// by expressions compiled from this session.
        /// </summary>
        XQueryContext Context {
            get;
        }

        /// <summary>
        /// Returns the private module resolver defined for the session.
        /// <para>null if no private module resolver was defined for the session</para>
        /// <para>a Module resolver; if set to null, the default module resolver will then be used for the session</para>
        /// </summary>
        ModuleResolver ModuleResolver {
            get;
            set;
        }

        /// <summary> Returns the private full-text word tokenizer defined for the session.</summary>
        /// <returns> the private full-text word tokenizer defined for the session. By
        /// default it is an instance of {@link DefaultWordSieve}
        /// </returns>
        /// <deprecated> see #getFulltextFactory #setFullTextFactory
        /// </deprecated>
        /// <summary> Defines the private full-text word tokenizer for the session. By
        /// default it is an instance of {@link DefaultWordSieve}.
        /// </summary>
        /// <throws>  DataModelException if the session is in fact an XML Library, </throws>
        /// <summary> changing the word sieve can generate an exception (for example if it
        /// is read-only).
        /// </summary>
        /// <deprecated> see #setFullTextFactory
        /// </deprecated>
        Indexing.WordSieve WordSieve {
            get;

            set;

        }

        /// <summary> <para>Returns the Fulltext Provider associated with the session.</para>
        /// <para>Redefines the full-text factory associated with the session. 
        /// <para>A FullTextFactory provides access to- or allows redefining full-text
        /// resources such as text tokenizer, stemming, thesaurus and scoring method.</para>
        /// <para>By default, an instance of {@link DefaultFullTextFactory} is used. It
        /// is also possible to define a FullTextFactory on the {@link LibraryManager}
        /// which controls a group of Libraries.</para>
        /// </summary>
        FullTextFactory FullTextFactory {
            get;

            set;

        }

        /// <summary>
        /// Creates an executable Expression by compiling a XQuery script.
        /// </summary>
        /// <param name="xquery">a string containing a XQuery script.</param>
        /// <returns>
        /// an executable Expression that can be used for several
        /// executions. Before an execution, the expression can be prepared
        /// by binding values with variables
        /// </returns>
        /// <exception cref="CompilationException">thrown after compilation if parsing or
        /// static analysis errors are detected. A CompilationException bears a list
        /// of {@link Message}s.
        /// </exception>
        Expression CompileExpression(string xquery);

        Expression CompileExpression(string xquery, IXmlNamespaceResolver resolver);

        /// <summary> Enables a class for the 'Java Binding' mechanism.
        /// <p>
        /// <b>Attention: </b>the Java Binding mechanism is not enabled by default
        /// when using the API. Each Java class has to be enabled specifically. It
        /// is possible to enable all classes at once (though not advisable for
        /// security reasons) by passing a null name.
        /// <p><b>Attention: </b>once a class has been enabled, it can no longer 
        /// be disabled in the same session.
        /// </summary>
        /// <param name="className">fully qualified class name (e.g
        /// java.sql.DriverManager). If the value 'null' is used instead of a
        /// class name, then <em>all Java</em> to Java extensions are
        /// enabled or disabled.
        /// </param>
        void EnableJavaBinding(string className);
    }
}